package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Order;
import com.itheima.vo.OrderSuccessInfoVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {

    @Select("select m.name as member,s.name as setmeal,date_format(order_date,'%Y-%m-%d') order_date from t_order o\n" +
            "left join t_member m on m.id = o.member_id\n" +
            "left join t_setmeal s on s.id = o.setmeal_id\n" +
            "where o.id = #{orderId}")
    public OrderSuccessInfoVO selectOrderSuccessInfo(@Param("orderId") Long orderId);

    /**
     * 各个套餐预约数
     * */
    @Select("select s.name ,count(*) as value\n" +
            "from t_order o\n" +
            "left join t_setmeal s on o.setmeal_id = s.id\n" +
            "group by setmeal_id")
    public List<Map> selectSetmealPercent();

}
